
/**
 *
 *! \file        servcust.h
 * \brief This module contains definitions for access to the EMV Custom Component
 *
	EMV Custom is a part of the EMV Generic architecture, for Telium Platform.
	It manages all treatments which are localisation dependent. In particular, it manages all human interface and
	EMV application parameters.
	It offers a set of services to the Engine Component, using the IAC communication mechanism.
	It must abide some rules, to enable a good integration into EMV Generic.
 *
 * \author        SMO
 * \author Copyright (c) 2001 Sagem Monetel SA, rue claude Chappe,
 * \author 07503 Guilherand-Granges, France, All Rights Reserved.
 *
 * \author Sagem Monetel SA has intellectual property rights relating
 * \author to the technology embodied in this software.  In particular, 
 * \author and without limitation, these intellectual property rights 
 * \author may include one or more patents.
 *
 * \author This software is distributed under licenses restricting 
 * \author its use, copying, distribution, and decompilation.  
 * \author No part of this software may be reproduced in any form 
 * \author by any means without prior written authorization of 
 * \author Sagem Monetel.

 *
 */
#ifndef _SERVCUST_H_
#define _SERVCUST_H_

/*-------------------------------------------------------------------------*/
#define I_EMVCUST_Type_Appli        81 /* Custom appli number             */


/*-------------------------------------------------------------------------*/
/* CUSTOM component services identification                                */
/*-------------------------------------------------------------------------*/
/** \defgroup EMVService EMV Service
@{ */
/** @defgroup CuServ Custom Services definition              
 *  @{											*/
#define I_EMVCUST_Initialise                100
#define I_EMVCUST_Get_Global_Param          101
#define I_EMVCUST_Get_AID_List              102
#define I_EMVCUST_Get_AID_DATA              103
#define I_EMVCUST_Get_AID_Param             104
#define I_EMVCUST_More_Function             105
#define I_EMVCUST_Periodic_Call             106
#define I_EMVCUST_Process_Step              107
#define I_EMVCUST_Display_Message           108
#define I_EMVCUST_Get_Last_Transaction      109
#define I_EMVCUST_Last_Transaction_Status   110
#define I_EMVCUST_Get_Data_Elements         111
#define I_EMVCUST_Set_Data_Elements         112
#define I_EMVCUST_Voice_Referral            113
#define I_EMVCUST_Get_AID					114
/*& BEGIN TEDT/Z3/02/1259/PBE								               */
#define I_EMVCUST_KeyManagement				115
/*& END TEDT/Z3/02/1259/PBE								                   */
/*& BEGIN SMO/ETU/04/20004/LB                                              */
#define I_EMVCUST_Authorisation				116
/*& END SMO/ETU/04/20004/LB                                                */
/*& BEGIN SMO/ETU/05/20085/LB                                              */
#define I_EMVCUST_Choose_Language_Menu		117
/*& END SMO/ETU/05/20085/LB                                                */
/** @} */
#define I_EMVCUST_Menu_Select				118
/*& BEGIN  FT/1126/06/MA : Account Type Selection						   */
#define I_EMVCUST_Choose_Account_Type_Menu	119
/*& END FT/1126/06/MA : Account Type Selection						   */

#define I_EMVCUST_Perform_Transaction		120

/*-------------------------------------------------------------------------*/
/** @defgroup CuServ Custom Services definition              
 *  @{											*/
/**
 * function:    EMVCUST_Initialise
 * @brief: Service called by EMV Engine after each reinitialisation of the terminal.
		It can be used for data initialisation, or any other initialisation treatments.
 * @author: SMO
 * @param aDEL contains the list of input parameters
 * @param  - #TAG_EG_IDENTIFICATION
 * @param  - #TAG_EG_VERSION
 * @return Output DEL containing
 * @return - #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Initialise(DEL *aDEL);


/**
 * function:    EMVCUST_Get_Global_Param
 * @brief: Service called by EMV Engine after each reinitialisation of the terminal,
		or after any change in parameters.
		This service returns all global EMV parameters (independent from AID).

  		EMV parameters are the parametes defined as Application Indepedent Data in EMV Requirements.
		Some internal parameters are also needed at this time.
	@see: EMV 2000, chapter 6.1 for further details on Application Independent Data
	@Note: Local Date and Time will be read at the beginning of the transaction.
	@Note: Transaction Sequence Counter is managed by EMVDC.

 * @author: SMO
 * @param aDEL contains the list of input parameters	: VOID
 * @return Output DEL containing
 * @return - #TAG_CUST_APPLI_NAME
 * @return - #TAG_CUST_IDLE_MESSAGE
 * @return - #TAG_TERMINAL_CAPABILITIES
 * @return - #TAG_ADD_TERMINAL_CAPABILITIES
 * @return - #TAG_TERMINAL_COUNTRY_CODE
 * @return - #TAG_TERMINAL_IDENTIFICATION
 * @return - #TAG_TERMINAL_TYPE
 * @return - #SCH_PINCODE_OFFLINE
 * @return - #TAG_EXTERNAL_FUNCTION
 * @return - #TAG_IFD_SERIAL_NUMBER
 * @return - #TAG_COMPATIBILITY_2000
 * @return - #TAG_USE_PSE
 * @return - #TAG_CUST_IS_COMM_MANAGED_BY_CUSTOM
 * @return - #TAG_WAIT_AFTER_ATR
 * @return - #TAG_CUST_SUPPORTED_LANGUAGE_LIST
 * @return - #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_Global_Param(DEL *aDEL);


/**
 * function:    EMVCUST_Get_AID_List
 * @brief: This service returns the list of managed AID.
 * @author: SMO
 * @param aDEL contains the list of input parameters	: VOID
 * @return Output DEL containing
 * @return - #TAG_AID_LIST_TERMINAL
 * @return - #TAG_NB_AID_TERMINAL
 * @return - #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_AID_List(DEL *aDEL);


/**
 * function:    EMVCUST_Get_AID
 * @brief: This service returns the list of managed AID, in the format
		required by M2OS.
 * @author: SMO
 * @param aDEL contains the list of elements to be read	: VOID
 * @return Output DEL containing
 * @return	- #TAG_GIVE_AID_MANUAL_SELECTION
 * @return	- #TAG_GIVE_AID_NB_AID
 * @return	- For each managed AID
 * @return		- #TAG_GIVE_AID_AID_VALUE
 * @return		- #TAG_GIVE_AID_ASI
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_AID(DEL *aDEL);


/**
 * function:    EMVCUST_Get_AID_DATA
 * @brief: This service returns the list of data elements related with one AID.

		Some of these data elements may overwrite data elements already given
		in the service EMVCUST_Get_Global_Param (ex : terminal capabilities).
		see EMV 2000, chapter 6.2 for further details on these elements.
 * @author: SMO
 * @param aDEL contains the list of input parameters
 * @param  - #TAG_AID_PROPRIETARY
 * @return Output DEL containing
 * @return	- #TAG_ACQUIRER_IDENTIFIER
 * @return	- #TAG_AID_PROPRIETARY
 * @return	- #TAG_VERSION_NUMBER_TERMINAL
 * @return	- #TAG_CERT_AUTH_PUB_KEY_CHECKSUM
 * @return	- #TAG_CERT_AUTH_PUB_KEY_INDEX_TERM
 * @return	- #TAG_DEFAULT_DDOL
 * @return	- #TAG_DEFAULT_TDOL
 * @return	- #TAG_MAX_TARG_PERC_FOR_BIASED_RAND_SEL
 * @return	- #TAG_MERCHANT_CATEGORY_CODE
 * @return	- #TAG_MERCHANT_IDENTIFIER
 * @return	- #TAG_TARG_PERC_FOR_BIASED_RAND_SEL
 * @return	- #TAG_TERMINAL_ACTION_CODE_DEFAULT
 * @return	- #TAG_TERMINAL_ACTION_CODE_DENIAL
 * @return	- #TAG_TERMINAL_ACTION_CODE_ONLINE
 * @return	- #TAG_TERMINAL_FLOOR_LIMIT
 * @return	- #TAG_TRESH_VALUE_FOR_BIASED_RAND_SEL
 * @return	- #TAG_TRANSACTION_CURRENCY_CODE
 * @return	- #TAG_TRANSACTION_CURRENCY_EXP
 * @return	- #TAG_TRANSACTION_REF_CURRENCY_CODE
 * @return	- #TAG_TRANSACTION_REF_CURRENCY_CONV
 * @return	- #TAG_TRANSACTION_REF_CURRENCY_EXP
 * @return	- #TAG_CUST_APPLICATION_SELECTION_ID
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_AID_DATA(DEL *aDEL);


/**
 * function:    EMVCUST_Get_AID_Param
 * @brief: This service returns some internal parameters related with one AID.

 * @author: SMO
 * @param aDEL contains the list of input parameters
 * @param  - #TAG_AID_PROPRIETARY
 * @return Output DEL containing
 * @return	- #TAG_TIME_OUT_PIN_CODE
 * @return	- #TAG_TIME_OUT_INTER_CAR
 * @return	- #TAG_CUST_IS_KSU
 * @return	- #TAG_CUST_IS_BLACK_LIST
 * @return	- #TAG_CUST_IS_PIN_BYPASS
 * @return	- #TAG_CUST_IS_ONLINE_ADVICE
 * @return	- #TAG_CUST_IS_OFFLINE_ADVICE
 * @return	- #TAG_CUST_IS_VOICE_REFERRAL
 * @return	- #TAG_CUST_IS_FORCED_ONLINE
 * @return	- #TAG_CUST_IS_FORCED_ACCEPTANCE
 * @return	- #TAG_CUST_IS_ONLINE_ADVICE_IF_FORCED_ACCEPTANCE
 * @return	- #TAG_CUST_COMM_TYPE_APPLI
 * @return	- #TAG_CUST_SERVICE_AUTHO_NUM
 * @return	- #TAG_TRANSACTION_TYPE
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_AID_Param(DEL *aDEL);


/**
 * function:    EMVCUST_More_Function
 * @brief: This service manages the EMV Generic menu

	EMV Engine calls this service in the M2OS entry-point more_function, to manage the different menus.
	At the end of the function, EMV Engine reads the application parameters again, 
	because some of them could have been modified.
	EMV Custom may require a transaction to be launched, at the end of this service.
 * @author: SMO
 * @param aDEL contains the list of input parameters
 * @param  - #TAG_EG_NUM_APPLI
 * @return Output DEL containing
 * @return	- #TAG_CUST_DEBIT_IS_ASKED
 * @return	- #TAG_AMOUNT_AUTH_BIN (only if a transaction is required)
 * @return	- #TAG_AMOUNT_AUTH_NUM (only if a transaction is required)
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_More_Function(DEL *aDEL);


/**
 * function:    EMVCUST_Periodic_Call
 * @brief: This service is called by EMV Engine to perform some periodic treatments, if needed.
 * @author: SMO
 * @param aDEL contains the list of input parameters : VOID
 * @return Output DEL containing
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Periodic_Call(DEL *aDEL);

/**
 * function:    EMVCUST_Process_Step
 * @brief: This service is called by EMV Engine after each step of an EMV transaction.
	It enables EMV Custom to make extra checks and treatments.
	The data exchanged are specific for each step.

	The steps of the transaction are the following ones :
	- EMVDC_START : 
		This step enables EMV Custom to initialise some transaction data.
	- EMVDC_APPLICATION_SELECTION : 
		EMV Engine calls this step after the final application selection. This does not
		apply in the case of transaction begun by a card insertion
		- Entry DEL :
			- #TAG_AID_PROPRIETARY
			- #TAG_EG_IS_AMOUNT_NEEDED
		- Output DEL
			- #TAG_AMOUNT_AUTH_BIN
			- #TAG_AMOUNT_AUTH_NUM
			- #TAG_TRANSACTION_DATE
			- #TAG_TRANSACTION_TIME
			- #TAG_PP_OK
			- #TAG_CUST_CA_REVOK_1
			- #TAG_BYPASS_PIN
			- #TAG_CUST_POS_ISO8583_93
			- #TAG_CUST_FORCED_ONLINE_REQUEST
	- EMVDC_INITIATE_APPLICATION_PROCESSING : 
		EMV Engine calls this step after Initiate Application Processing step (command
		Get_Processing_Option.
	- EMVDC_READ_APPLICATION_DATA : 
		EMV Engine calls this step after having read the application records in the card.
		- Output DEL
			- #TAG_CUST_PAN_IN_BLACK_LIST
			- #TAG_CERT_AUTH_PUB_KEY_MODULUS
			- #TAG_CERT_AUTH_PUB_KEY_EXPONENT
	- EMVDC_OFFLINE_DATA_AUTHENTICATION : 
		EMV Engine calls this step after the Data Authentication Step.
	- EMVDC_ODA_EXTERN_INIT : 
		This step is called only in case of Data Authentication is externalised.
	- EMVDC_ODA_EXTERN_INTERNAL_AUTHENTICATE : 
		This step is called only in case of Data Authentication is externalised.
	- EMVDC_ODA_EXTERN_RESULT : 
		This step is called only in case of Data Authentication is externalised.
	- EMVDC_PROCESSING_RESTRICTIONS : 
		This step is called at the end of the Processing Restrictions step.
	- EMVDC_CARDHOLDER_VERIFICATION_FIRST : 
		This step is called at the Cardholder Verification Method step, to perform the
		human interface related with the first method. EMV Custom shall perform the pin entry
		if needed. The PIN code shall be kept in the Booster processor.
		- Entry DEL :
			- #TAG_EG_CARDHOLDER_LANGUAGE
			- #TAG_SIGNATURE
			- #TAG_STATUS_CVP
		- Output DEL
			- #TAG_AUTOMATE
			- #TAG_BYPASS_PIN
	- EMVDC_CARDHOLDER_VERIFICATION_OTHER : 
		This step is called at the Cardholder Verification Method step, to perform the
		human interface related with the methods after the first one.
		The interface is the same as for EMVDC_CARDHOLDER_VERIFICATION_FIRST.
	- EMVDC_TERMINAL_RISK_MANAGEMENT : 
		This step is called at the end of the Terminal Risk Management step.
	- EMVDC_TERMINAL_ACTION_ANALYSIS : 
		This step is called at the end of the Terminal Action Analysis step.
	- EMVDC_CARD_ACTION_ANALYSIS : 
		This step is called at the end of the Card Action Analysis step.
		- Output DEL
			- #TAG_TRANSACTION_FORCED_ACCEPTANCE (if needed)
	- EMVDC_ON_LINE_PROCESSING : 
		This step is called at the end of the Online Processing step.
		- Entry DEL :
			- #TAG_CUST_IS_COMMUNICATION_OK
		- Output DEL
			- #TAG_TRANSACTION_FORCED_ACCEPTANCE (if needed)
	- EMVDC_ISSUER_TO_CARD_SCRIPT_PROCESSING1 : 
		This step is called at the end of the First Script Processing step (before
		second generate_ac)
	- EMVDC_COMPLETION : 
		This step is called at the end of the completion step.
		- Output DEL
			- #TAG_TRANSACTION_FORCED_ACCEPTANCE (if needed)
	- EMVDC_ISSUER_TO_CARD_SCRIPT_PROCESSING2 : 
		This step is called at the end of the second Script Processing step (after
		second generate_ac)
	- EMVDC_STOP : 
		This step is called after the card has been powered off.

 * @author: SMO
 * @param function
 * @param aDEL contains the list of input parameters
 * @param - #TAG_SERVICE_STATUS_CODE
 * @param - Other data : see description for each step.
 * @return Output DEL containing
 * @return	- #TAG_CUST_STATUS_CODE
 * @return	- Other data : see description for each step.
 */
DEL* EMVCUST_Process_Step(int function, DEL *aDEL);

/**
 * function:    EMVCUST_Display_Message
 * @brief: This service enables EMV ENGINE to display a standard message.

  If the message is to be displayed to the cardholder, EMV ENGINE may add a code with Cardholder Language, 
  corresponding to Cardholder Preferred Language read on the card.
 * @see: EMV 2000, book 4, 7.2
 * @author: SMO

 * @param aDEL contains the list of input parameters
 * @param  - #TAG_EG_CARDHOLDER_LANGUAGE
 * @param  - #TAG_EG_MESSAGE_CODE_NUM
 * @return Output DEL containing
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Display_Message(DEL *aDEL);


/**
 * function:    EMVCUST_Get_Last_Transaction
 * @brief: This service returns info about the last transaction

	This service asks EMV CUSTOM to search in its data batch for the last transaction done with the current card.
	It is used by EMV ENGINE to retrieve the amount of the last transaction, for floor limits management.

 * @see: EMV 2000, book 3, 6.6.1
 * @author: SMO

 * @param aDEL contains the list of input parameters
 * @param  - TAG_APPLI_PRIM_ACCOUNT_NB
 * @return Output DEL containing
 * @return	- #TAG_AMOUNT_AUTH_BIN
 * @return	- #TAG_AMOUNT_OTHER_BIN
 * @return	- #TAG_LAST_TR_AMOUNT_BIN
 * @return	- #TAG_LAST_TR_CURRENCY_CODE
 * @return	- #TAG_TRANSACTION_DATE
 * @return	- #TAG_TRANSACTION_TIME
 * @return	- #TAG_TRANSACTION_TYPE
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Get_Last_Transaction(DEL *aDEL);


//DEL* EMVCUST_Last_Transaction_Status(unsigned short *ServiceStatusCode, T_CUSERV_LastTransStatus *LastTransStatus);
//DEL* EMVCUST_Get_Data_Elements(DEL *aDEL);
//DEL* EMVCUST_Set_Data_Elements(DEL *aDEL);



/**
 * function:    EMVCUST_Voice_Referral
 * @brief: This service performs a voice referral whether it is asked by the card or by the host.

 * @see: EMV 2000, book 4, 2.5.2
 * @author: SMO

 * @param aDEL contains the list of input parameters
 * @param  - TAG_EG_REFERRAL_CARD
 * @return Output DEL containing
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_Voice_Referral(DEL *aDEL);


/*& BEGIN TEDT/Z3/02/1259/PBE								*/
/**
 * function:    EMVCUST_KeyManagement
 * @brief: This service manages the treatments associated with key entries.

	EMV Engine calls this service in the M2OS entry-point keyboard_event, to manage optionally key entries.
	For each key entry, EMV Engine calls the service, in return Custom tells Engine whether the key is captured or not, 
	and the appropriate action to be taken.
	EMV Custom may require a transaction to be launched, at the end of this service.
 * @author: SMO
 * @param aDEL contains the list of input parameters
 * @param  - #TAG_EG_NUM_APPLI
 * @param  - #TAG_EG_TYPE_KEY_PRESSED
 * @return Output DEL containing
 * @return  - #TAG_EG_TYPE_KEY_PRESSED
 * @return	- #TAG_CUST_DEBIT_IS_ASKED
 * @return	- #TAG_AMOUNT_AUTH_BIN (only if a transaction is required)
 * @return	- #TAG_AMOUNT_AUTH_NUM (only if a transaction is required)
 * @return	- #TAG_CUST_STATUS_CODE
 */
DEL* EMVCUST_KeyManagement(DEL *aDEL);
/*& END TEDT/Z3/02/1259/PBE								*/

/*& BEGIN SMO/ETU/04/20004/LB                                              */
/**
 * function:    EMVCUST_Authorisation
 * @brief: This service manages the authorisation request, in the case EMV CUSTOM fully
   manages the interface with the acquirer host.

	This service prepares an authorisation message, manages the exchanges with the host,
	possibly with the use of a COMM component.
	The returned values are those listed in EMV2000, book 4, 8.1.3.
	The return code is the tag TAG_COMM_STATUS_CODE
 * @author: SMO
 * @param aDEL contains the list of input parameters : VOID
 * @return Output DEL containing
 * @return	- TAG_COMM_STATUS_CODE
 * @return	- tags listed in EMV 2000, book 4, 8.1.3
 */
DEL* EMVCUST_Authorisation (DEL *aDEL);
/*& END SMO/ETU/04/20004/LB                                                */

/*& BEGIN SMO/ETU/05/20085/LB                                              */
/**
 * function:    EMVCUST_Choose_Language_Menu
 * @brief: This service asks the cardholder to chose a language in the list
	of supported langages.
	The return code is the tag TAG_COMM_STATUS_CODE
 * @author: SMO
 * @param aDEL contains the list of input parameters : VOID
 * @return Output DEL containing
 * @return	- #TAG_CUST_STATUS_CODE
 * @return	- #TAG_EG_CARDHOLDER_LANGUAGE
 */
DEL* EMVCUST_Choose_Language_Menu (DEL *aDEL);
/*& END SMO/ETU/05/20085/LB                                                */

DEL* EMVCUST_Menu_Select (DEL *aDEL);

/*&BEGIN FT/1126/06/MA : Account Type Selection						   */
DEL *EMVCUST_Choose_Account_Type_Menu (DEL *aDEL);
/*&END FT/1126/06/MA : Account Type Selection						   */

/** @} */
/** @} */

#endif
